package com.ticket.web.controller.yanchu;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ticket.common.annotation.Log;
import com.ticket.common.core.controller.BaseController;
import com.ticket.common.core.domain.AjaxResult;
import com.ticket.common.enums.BusinessType;
import com.ticket.system.domain.YanchuRechargeRules;
import com.ticket.system.service.IYanchuRechargeRulesService;
import com.ticket.common.core.page.TableDataInfo;

/**
 * 充值活动规则Controller
 * 
 * @author ruoyi
 * @date 2023-12-07
 */
@RestController
@RequestMapping("/system/rules")
@Api("充值活动规则")
public class YanchuRechargeRulesController extends BaseController
{
    @Autowired
    private IYanchuRechargeRulesService yanchuRechargeRulesService;


    @ApiOperation("查询充值活动规则列表")
    @PreAuthorize("@ss.hasPermi('system:rules:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<YanchuRechargeRules> list = yanchuRechargeRulesService.selectYanchuRechargeRulesList(new YanchuRechargeRules());
        return getDataTable(list);
    }

    @ApiOperation("小程序查询充值活动规则列表")
    @GetMapping("/listMobile")
    public TableDataInfo listMobile()
    {
        startPage();
        List<YanchuRechargeRules> list = yanchuRechargeRulesService.selectYanchuRechargeRulesList(new YanchuRechargeRules());
        return getDataTable(list);
    }

    @ApiOperation("获取充值活动规则详细信息")
    @PreAuthorize("@ss.hasPermi('system:rules:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yanchuRechargeRulesService.selectYanchuRechargeRulesById(id));
    }

    @ApiOperation("新增充值活动规则")
    @PreAuthorize("@ss.hasPermi('system:rules:add')")
    @Log(title = "充值活动规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YanchuRechargeRules yanchuRechargeRules)
    {
        return toAjax(yanchuRechargeRulesService.insertYanchuRechargeRules(yanchuRechargeRules));
    }

    @ApiOperation("修改充值活动规则")
    @PreAuthorize("@ss.hasPermi('system:rules:edit')")
    @Log(title = "充值活动规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YanchuRechargeRules yanchuRechargeRules)
    {
        return toAjax(yanchuRechargeRulesService.updateYanchuRechargeRules(yanchuRechargeRules));
    }

    @ApiOperation("删除充值活动规则")
    @PreAuthorize("@ss.hasPermi('system:rules:remove')")
    @Log(title = "充值活动规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yanchuRechargeRulesService.deleteYanchuRechargeRulesByIds(ids));
    }
}
